package com.lovelc.cn.controller;

import com.alibaba.druid.pool.DruidDataSource;
import com.lovelc.cn.procesor.MyDataSource;
import com.lovelc.cn.service.DataSourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @ClassName TestController
 * @Description 测试controller
 * @Author huangjh5
 * @Date 2021/1/4 15:36
 */
@Slf4j
@RestController
public class TestController {

    @Resource
    private DataSource dataSource;

    @Resource
    private DataSourceService dataSourceService;



    @RequestMapping(value="/changeDataInfo")
    public String changeData(String name,String passwd,String url) {
        //修改jdbc的连接
        return "";
    }

    @RequestMapping(value = "info")
    public String info() {
        return "dataSource,url:" + ((MyDataSource)dataSource).getUrl()
                +" name :"+((MyDataSource)dataSource).getUsername()
                +" password :"+((MyDataSource)dataSource).getPassword();
    }


    @RequestMapping(value = "test")
    public String test() {
        dataSourceService.save();
        return "dataSource,url:" + ((MyDataSource)dataSource).getUrl()
                +" name :"+((MyDataSource)dataSource).getUsername()
                +" password :"+((MyDataSource)dataSource).getPassword();
    }



}
